//
//  NSString+Util.m
//
//  Created by SKY
//  Copyright © 翊sky. All rights reserved.
//

#import "NSString+Util.h"

@implementation NSString (Util)

-(CGFloat)widthWithMaxHeight:(CGFloat)maxHeight attributes:(NSDictionary *)attributes{
    CGRect frame = [self boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, maxHeight) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];
    
    return frame.size.width;
}
-(CGFloat)heightWithMaxWidth:(CGFloat)maxWidth attributes:(NSDictionary *)attributes{
    CGRect frame = [self boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];
    
    return frame.size.height;
}

-(NSString *)day{
    NSArray *timeArray = [self componentsSeparatedByString:@"-"];
    return timeArray[2];
}
-(NSString *)month_true{
    NSArray *timeArray = [self componentsSeparatedByString:@"-"];
    return timeArray[1];
}
-(NSString *)month{
    
    NSArray *timeArray = [self componentsSeparatedByString:@"-"];
    NSArray *dateArray = @[@"January",@"February",@"March",
                           @"April",@"May",@"June",
                           @"July",@"August",@"September",
                           @"October",@"November",@"December"];
    
    return dateArray[[NSString stringWithFormat:@"%@",timeArray[1]].intValue-1];
}
-(NSString *)year{
    NSArray *timeArray = [self componentsSeparatedByString:@"-"];
    return timeArray[0];
}

@end
